package org.example.atomic;

import org.junit.jupiter.api.Test;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * file:AtomicTest.class
 * function:
 *
 * @author shaodan wang
 * @date 2024-06-22
 */

public class AtomicTest {

    @Test
    public void testAtomicInteger(){
        AtomicInteger atomicInteger = new AtomicInteger(10);
        atomicInteger.updateAndGet(operand -> {
            if(operand > 0){
                operand--;
            }
            return operand;
        });
    }
}
